<?php
    namespace Npfe\Controller;
    use Think\Controller;
    Class XiadanController extends Controller {
        function index(){
            $this->assign(array('now_user'=>session('uid'),'now_em'=>session('nickname'),'gdlb'=>$this->Getgdlb()));
            $this->display();
        }
        private function Getgdlb(){
            $gdlb = new \Npfe\Model\GdlbModel();
            $data = $gdlb->select();
            $xml = '';
            foreach($data as $value){
                $xml .= '<option value = "'.$value[lbmc].'">'.$value[lbtitle].'</option>';
            }
            return $xml;
        }
        public function SubmitGD() {
        	$glxq = new \Npfe\Model\GlxqModel();
        	$data = array(
        		'submitnumber' => I('post.shengaohao'),
        		'contactnumber' => I('post.lianxihao'),
        		'gdlbvalue' => I('post.xdlb'),
        		'content' => I('post.contents','',false),
        		'time' => date("Y-m-d H:m:s"),
        		'customername' => I('post.kehuxingming'),
        		'idnumber' => I('post.cridnumber'),
        		'idcardaddress' => I('post.craddress'),
        		'orderman' => session('nickname')
        	);
            if($data['submitnumber'] == '0040'){
               $data['hff'] = 'true';
            }
        	$res = $glxq->add($data);
        	$this->ajaxReturn($res);
        }
        public function CheckRep() {
        	$glxq = new \Npfe\Model\GlxqModel();
        	$data = $glxq->where(array('contactnumber'=>I('post.lianxihao')))->find();
        	if (!$data) {
        		$this->ajaxReturn('norep');
        	}elseif ($data == NULL){
        		$this->ajaxReturn('norep');
        	}else {
        		if ($data['isend']=='正在处理') {
        			$this->ajaxReturn('rep&runing');
        		}else{
        			$this->ajaxReturn('rep');
        		}
        	}
        	
        }
    }
?>
